package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.Weibo;
import cn.tedu._04mybatis.pojo.vo.*;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface WeiboMapper {

    /*@Insert("INSERT INTO weibo(content,created,user_id) " +
            "VALUES (#{content},#{created},#{userId})")*/
    int weiboAdd(Weibo weibo);

    //@Delete("DELETE FROM weibo WHERE id=#{id}")
    int weiboDelete(long id);

    /*@Update("UPDATE weibo SET content=#{content},created=#{created},user_id=#{userId} " +
            "WHERE id =#{id}")*/
    int weiboUpdate(Weibo weibo);

    //@Select("SELECT id,content,created,user_Id userId FROM weibo WHERE id=#{id}")
    Weibo selectWeiboById(long id);

    //@Select("SELECT id,content,created,user_Id FROM weibo WHERE user_Id=#{uid}")
    List<Weibo> selectWeiboByUserId(long uid);

    //@Select("SELECT content ,created FROM weibo WHERE id=#{id}")
    WeiboVo1 selectWeiboVo1ById(long id);

    /*@Select("SELECT nickname,content,weibo.created\n" +
            "FROM weibo\n" +
            "JOIN user ON weibo.user_id =user.id\n" +
            "WHERE user.id=#{id}")*/
    List<WeiboVo2> selectWeiboVo2ById(long id);

    int dynamicUpdate(Weibo weibo);
//动态删除（集合形式）
    int dynamicDelete(ArrayList<Long> ids);
//动态删除（数组形式）
    int dynamicDelete2(Long[] ids);

    int selectCount();

    ResultMapVo1 selectMap1(Long id);

    ResultMapVo2 selectMap2(Long uid);

    ResultMapVo3 selectMap3(Long wid);

    ResultMapVo4 selectMap4(Long wid);


}
